﻿using System;
using System.Web.UI.WebControls;
using Business;

namespace TimeWork
{
    public partial class Client : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["email"] == null)
            {
                Response.Redirect("http://"+Request.Url.Authority+"/Login.aspx");
            }
            if (!IsPostBack)
            {
                FillGrid();
            }
        }

        private void FillGrid()
        {
            GVListClient.DataSource = BuClient.selAllClient(Session["companyid"].ToString());
            GVListClient.DataBind();
        }
        protected void GVListStaff_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                HyperLink hplClientName = (HyperLink)e.Row.FindControl("hplClientName");
                if (hplClientName != null)
                {
                    hplClientName.NavigateUrl = "~/time/admin/EditClient.aspx?cid=" + GVListClient.DataKeys[e.Row.RowIndex].Values[0].ToString();
                }
            }
        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/time/admin/CreateClient.aspx");
        }
    }
}